<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">视频图片</label>
        <div class="layui-input-block">
            <input type="text" name="movie_Name" lay-verify="required" lay-reqtext="视频图片不能为空" placeholder="请存入视频图片" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">视频名称</label>
        <div class="layui-input-block">
            <input type="text" name="movie_Name" lay-verify="required" lay-reqtext="视频名称用户名不能为空" placeholder="请输入视频名称" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">视频译名</label>
        <div class="layui-input-block">
            <input type="text" name="movie_ChineseName" lay-verify="required" lay-reqtext="视频译名不能为空" placeholder="请输入视频译名" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">年代</label>
        <div class="layui-input-block">
            <input type="text" name="movie_Age" lay-verify="required" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">产地</label>
        <div class="layui-input-block">
            <input type="text" name="movie_Place" lay-verify="required" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">类别</label>
        <div class="layui-input-block">
            <input type="text" name="movie_Type" lay-verify="required" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">语言</label>
        <div class="layui-input-block">
            <input type="text" name="movie_Language" lay-verify="required" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">字幕</label>
        <div class="layui-input-block">
            <input type="text" name="movie_Subtitle" lay-verify="required" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">上映时间</label>
        <div class="layui-input-block">
            <input type="text" name="movie_ReleaseDate" id="date1" autocomplete="off" class="layui-input"
                   lay-verify="required" lay-reqtext="上映时间不能为空"/>
        </div>

    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">IMDb评分</label>
        <div class="layui-input-block">
            <input type="text" name="movie_IMDbScore" lay-verify="required" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">豆瓣评分</label>
        <div class="layui-input-block">
            <input type="text" name="movie_DBScore" lay-verify="required" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">片长</label>
        <div class="layui-input-block">
            <input type="text" name="movie_Times" lay-verify="required" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">导演</label>
        <div class="layui-input-block">
            <input type="text" name="movie_Director" lay-verify="required" lay-reqtext="导演不能为空" placeholder="请输入导演名字" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">编剧</label>
        <div class="layui-input-block">
            <input type="text" name="movie_Scriptwriter" lay-verify="required" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">主演</label>
        <div class="layui-input-block">
            <input type="text" name="movie_Actor" lay-verify="required" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">简介</label>
        <div class="layui-input-block">
            <textarea name="remark" class="movie_Introduction" placeholder="请输入视频简介"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">视频链接</label>
        <div class="layui-input-block">
            <input type="text" name="movie_Actor" lay-verify="required" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
</div>
<script src="../../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="../../../lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>

<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate;

        laydate.render({
            elem: '#date1'
        });


        //$ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            layer.confirm('请确保信息是正确的哦！', function (index) {
                $.ajax({
                    url: "/api/movies?method=addMovies",
                    type: "post",
                    data: data.field,
                    dataType: "json",
                    success: function (data) {
                        console.log(data);
                        if (data.code === 200) {
                            //layer.msg('添加成功', function () {
                            window.location = '../movieslist.html';
                            //});
                        } else if (data.code === 500) {
                            layer.msg(data.msg, function () {
                                window.location = '../movieslist.html';
                            });
                        }
                    }
                });
            });
            return false;
        });

    });
</script>
</body>
</html>